{% from 'admin/common/_macro.html' import  authAction,no_img,default_img,render_page_data%}
{%  extends "admin/common/base.html" %}

{% block body -%}
<body class="hold-transition skin-blue fixed sidebar-mini">
<div class="wrapper">
    <header class="main-header">
    <!-- Logo -->
    <a href="{{ url_for('adminindex.index') }}" class="logo">
       <span class="logo-mini"><b>PF</b></span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>PF</b>CMS</span>
    </a>
    <!-- 右上导航 -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
      </a>

      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <li class="dropdown messages-menu">
             <a href="/" target="_blank">网站首页</a>
          </li>
          <li class="dropdown messages-menu">
             <a href="javascript:void(0)" data-url="{{ url_for('adminindex.clear_cache') }}" data-id="1" class="delete-one">清除缓存</a>
          </li>
          <li class="dropdown user user-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
              <img src="{{default_img(g.admin.img)}}" class="user-image" alt="User Image">
              <span class="hidden-xs">{{ g.admin.admin_name }}</span>
            </a>
            <ul class="dropdown-menu">
              <!-- User image -->
              <li class="user-header">
                <img src="{{default_img(g.admin.img)}}" class="img-circle" alt="User Image">

                <p>
                  {{ g.admin.admin_name }}
                  <small>{{ g.role_name }}</small>
                </p>
              </li>
              <li class="user-footer">
                <div class="pull-left">
                  <a href="{{ url_for('adminadmin.edit',id=g.admin.id) }}" class="btn btn-default btn-flat">个人设置</a>
                </div>
                <div class="pull-right">
                  <a href="{{ url_for('adminlogin.logout') }}" class="btn btn-default btn-flat">退出</a>
                </div>
              </li>
            </ul>
          </li>


        </ul>
      </div>
    </nav>
  </header>
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
          <!-- Sidebar user panel -->
          <div class="user-panel">
            <div class="pull-left image">
              <img src="{{default_img(g.admin.img)}}" class="img-circle" alt="User Image">
            </div>
            <div class="pull-left info">
              <p>{{default_img(g.admin.admin_name)}}</p>
              <a href="#"><i class="fa fa-circle text-success"></i>在线</a>
            </div>
          </div>
          <!--搜索-->
          <div  class="sidebar-form">
            <div class="input-group">
              <input type="text" name="q"  id="search-btn-value" class="form-control" placeholder="搜索">
              <span class="input-group-btn">
                    <button type="submit" name="search" id="search-btn" class="search-btn-menu btn btn-flat"><i class="fa fa-search"></i>
                    </button>
              </span>
            </div>
          </div>
            <script>
                $(function () {

                    $(".search-btn-menu ").on('click',function () {
                        var data_value = $("#search-btn-value").val().trim()
                        $('.menu_check').each(function () {
                            var obj = $(this)
                            var search_content = obj.html()
                            if (search_content.indexOf(data_value) >= 0) {
                                if (obj.parent().parent().hasClass('treeview-menu')) {
                                    if (obj.parent().parent().parent().hasClass('active') == false) {
                                        obj.parent().parent().prev().trigger('click')
                                        obj.trigger('click')
                                    } else {
                                        obj.trigger('click')
                                    }
                                } else {
                                    obj.trigger('click');
                                }
                                return false
                            }
                        })
                    })
                })
            </script>
          <!-- /.search form -->
          <!-- sidebar menu: : style can be found in sidebar.less -->
             <ul class="sidebar-menu">
                  <li class="header">菜单</li>
                 {% for v in menu -%}
                     {% if have_auth == 'all' or v.id|string  in have_auth -%}
                      <li class="treeview">
                          <a href="javascript:void(0);" class="menu_check">
                              <i class="{{ v.icon }}"></i><span>{{ v.pri_name }}</span>
                              {% if v.is_treeview == True -%}
                                  <span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span>
                              {%- endif %}
                          </a>
                          <ul class="treeview-menu">
                          {% if v.is_treeview == True -%}
                              {% for vv in v.child -%}
                                   {% if have_auth == 'all' or vv.id|string in have_auth -%}
                                       {%- if '?' in vv.action_name -%}
                                           {% set href = url_for(vv.url_prefix+'.'+vv.action_name.split('?')[0])+"?"+vv.action_name.split('?')[1] %}
                                       {%- else -%}
                                           {% set href= url_for(vv.url_prefix+'.'+vv.action_name) %}
                                       {%- endif -%}
                                       <li>
                                           <a class="menu_check"  href="{{ href }}">
                                               <i class="{{ vv.icon }}"></i>{{ vv.pri_name }}
                                               {% if vv.is_treeview == True -%}
                                                   <span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span>
                                               {%- endif %}
                                           </a>
                                            {% if vv.is_treeview == True -%}
                                                <ul class="treeview-menu">
                                                    {% for vvv in vv.child -%}
                                                        <li ><a class="menu_check" href="{{ url_for(vvv.url_prefix+'.'+vvv.action_name) }}"><i class="{{ vvv.icon }}"></i>{{ vvv.pri_name }}</a></li>
                                                    {%- endfor %}
                                                </ul>
                                            {%- endif %}
                                       </li>
                                   {%- endif %}
                              {%- endfor %}
                          {%- endif %}
                          </ul>
                      </li>
                     {%- endif %}
                 {%- endfor %}
              </ul>

        </section>
        <!-- /.sidebar -->
    </aside>



    <div class="content-wrapper" id="pjax-container">

      <section class="content-header">
        <h1>
          {% block page_title%}{% endblock %}
        </h1>
        <ol class="breadcrumb">
          <li><a href="#"><i class="fa fa-dashboard"></i> {% block page_btn_name%}{% endblock %}</a></li>
        </ol>
      </section>
        {% block content%}{% endblock %}
    </div>


     <!-- 底部很少改变的  -->
      <footer class="main-footer">
        <div class="pull-right hidden-xs">
          <b>Version</b> ls 1.0
        </div>
        <input id="fileupload_" type="file" style='display:none' name="imgFile"  data-url="{{ url_for('adminupload.upload') }}?dir=image" multiple>
        <strong>Copyright &copy; 2017-2018 <a target="_blank"  href="/">yxx</a>.</strong> All rights
        reserved.
      </footer>


</div>
{%- endblock %}
